usbcpower3 2.2.0
Loading...
Searching...
No Matches
usbcpower3.h File Reference

This file contains API for USB-C Power 3 Click Driver. More...

#include "drv_digital_out.h"
#include "drv_digital_in.h"
#include "drv_i2c_master.h"

Go to the source code of this file.

Data Structures

struct  usbcpower3_ptn_info_t
 USB-C Power 3 Click PTN info object. More...
struct  usbcpower3_t
 USB-C Power 3 Click context object. More...
struct  usbcpower3_cfg_t
 USB-C Power 3 Click configuration object. More...

Macros

#define USBCPOWER3_PTN_REG_VENDOR_ID   0x00
 USB-C Power 3 PTN USB PD register list.
#define USBCPOWER3_PTN_REG_PRODUCT_ID   0x02
#define USBCPOWER3_PTN_REG_DEVICE_ID   0x04
#define USBCPOWER3_PTN_REG_USBTYPEC_REV   0x06
#define USBCPOWER3_PTN_REG_USBPD_REV_VER   0x08
#define USBCPOWER3_PTN_REG_PD_INTERFACE_REV   0x0A
#define USBCPOWER3_PTN_REG_ALERT   0x10
#define USBCPOWER3_PTN_REG_ALERT_MASK   0x12
#define USBCPOWER3_PTN_REG_POWER_STATUS_MASK   0x14
#define USBCPOWER3_PTN_REG_FAULT_STATUS_MASK   0x15
#define USBCPOWER3_PTN_REG_EXTENDED_STATUS_MASK   0x16
#define USBCPOWER3_PTN_REG_ALERT_EXTENDED_MASK   0x17
#define USBCPOWER3_PTN_REG_CONFIGURE_STANDARD_OUTPUT   0x18
#define USBCPOWER3_PTN_REG_TCPC_CONTROL   0x19
#define USBCPOWER3_PTN_REG_ROLE_CONTROL   0x1A
#define USBCPOWER3_PTN_REG_FAULT_CONTROL   0x1B
#define USBCPOWER3_PTN_REG_POWER_CONTROL   0x1C
#define USBCPOWER3_PTN_REG_CC_STATUS   0x1D
#define USBCPOWER3_PTN_REG_POWER_STATUS   0x1E
#define USBCPOWER3_PTN_REG_FAULT_STATUS   0x1F
#define USBCPOWER3_PTN_REG_EXTENDED_STATUS   0x20
#define USBCPOWER3_PTN_REG_ALERT_EXTENDED   0x21
#define USBCPOWER3_PTN_REG_COMMAND   0x23
#define USBCPOWER3_PTN_REG_DEVICE_CAPABILITIES_1   0x24
#define USBCPOWER3_PTN_REG_DEVICE_CAPABILITIES_2   0x26
#define USBCPOWER3_PTN_REG_STANDARD_INPUT_CAPABILITIES   0x28
#define USBCPOWER3_PTN_REG_STANDARD_OUTPUT_CAPABILITIES   0x29
#define USBCPOWER3_PTN_REG_CONFIGURE_EXTENDED1   0x2A
#define USBCPOWER3_PTN_REG_GENERIC_TIMER   0x2C
#define USBCPOWER3_PTN_REG_MESSAGE_HEADER_INFO   0x2E
#define USBCPOWER3_PTN_REG_RECEIVE_DETECT   0x2F
#define USBCPOWER3_PTN_REG_READABLE_BYTE_COUNT   0x30
#define USBCPOWER3_PTN_REG_TRANSMIT   0x50
#define USBCPOWER3_PTN_REG_I2C_WRITE_BYTE_COUNT   0x51
#define USBCPOWER3_PTN_REG_VBUS_VOLTAGE   0x70
#define USBCPOWER3_PTN_REG_VBUS_SINK_DISCONNECT_THLD   0x72
#define USBCPOWER3_PTN_REG_VBUS_STOP_DISCHARGE_THLD   0x74
#define USBCPOWER3_PTN_REG_VBUS_VOLTAGE_ALARM_HI_CFG   0x76
#define USBCPOWER3_PTN_REG_VBUS_VOLTAGE_ALARM_LO_CFG   0x78
#define USBCPOWER3_PTN_REG_VBUS_HV_TARGET   0x7A
#define USBCPOWER3_PTN_REG_EXT_CFG_ID   0x80
#define USBCPOWER3_PTN_REG_EXT_ALERT   0x82
#define USBCPOWER3_PTN_REG_EXT_ALERT_MASK   0x84
#define USBCPOWER3_PTN_REG_EXT_CONFIG   0x86
#define USBCPOWER3_PTN_REG_EXT_FAULT_CONFIG   0x88
#define USBCPOWER3_PTN_REG_EXT_CONTROL   0x8E
#define USBCPOWER3_PTN_REG_EXT_STATUS   0x90
#define USBCPOWER3_PTN_REG_EXT_GPIO_CONFIG   0x92
#define USBCPOWER3_PTN_REG_EXT_GPIO_CONTROL   0x93
#define USBCPOWER3_PTN_REG_EXT_GPIO_ALERT_CONFIG   0x94
#define USBCPOWER3_PTN_REG_EXT_GPIO_STATUS   0x96
#define USBCPOWER3_PTN_REG_SOURCE_HIGH_VOLTAGE_MB4B_T   0x97
#define USBCPOWER3_PTN_REG_ADC_FILTER_CONTROL_1   0x9A
#define USBCPOWER3_PTN_REG_ADC_FILTER_CONTROL_2   0x9B
#define USBCPOWER3_PTN_REG_VCONN_CONFIG   0x9C
#define USBCPOWER3_PTN_REG_VCONN_FAULT_DEBOUNCE   0x9D
#define USBCPOWER3_PTN_REG_VCONN_FAULT_RECOVERY   0x9E
#define USBCPOWER3_PTN_REG_VCONN_FAULT_ATTEMPTS   0x9F
#define USBCPOWER3_ACT_REG_MASTER_CONTROL_1   0x00
 USB-C Power 3 ACT buck-boost converter register list.
#define USBCPOWER3_ACT_REG_MASTER_CONTROL_2   0x01
#define USBCPOWER3_ACT_REG_GENERAL_STATUS   0x02
#define USBCPOWER3_ACT_REG_THERMAL_STATUS   0x03
#define USBCPOWER3_ACT_REG_FAULT_1   0x05
#define USBCPOWER3_ACT_REG_FAULT_2   0x06
#define USBCPOWER3_ACT_REG_ADC_OUTPUT_1   0x07
#define USBCPOWER3_ACT_REG_ADC_OUTPUT_2   0x08
#define USBCPOWER3_ACT_REG_ADC_CONFIG_1   0x09
#define USBCPOWER3_ACT_REG_ADC_CONFIG_2   0x0A
#define USBCPOWER3_ACT_REG_VREG_CONTROL   0x0B
#define USBCPOWER3_ACT_REG_CONVERTER_CONTROL_1   0x0E
#define USBCPOWER3_ACT_REG_CONVERTER_CONTROL_2   0x0F
#define USBCPOWER3_ACT_REG_CONVERTER_CONTROL_3   0x10
#define USBCPOWER3_ACT_REG_VREG_VOLTAGE   0x11
#define USBCPOWER3_ACT_REG_OUTPUT_VOLTAGE_1   0x13
#define USBCPOWER3_ACT_REG_OUTPUT_VOLTAGE_2   0x14
#define USBCPOWER3_ACT_REG_OUTPUT_CURRENT_LIMIT   0x17
#define USBCPOWER3_ACT_REG_VIN_UV   0x1A
#define USBCPOWER3_ACT_REG_FREQUENCY   0x1D
#define USBCPOWER3_ACT_REG_IRQ_CONTROL_1   0x1E
#define USBCPOWER3_ACT_REG_IRQ_CONTROL_2   0x1F
#define USBCPOWER3_ACT_REG_VOUT_STATUS   0x20
#define USBCPOWER3_PTN_VENDOR_ID   0x1FC9
 USB-C Power 3 PTN USB PD VENDOR_ID and PRODUCT_ID registers setting.
#define USBCPOWER3_PTN_PRODUCT_ID   0x5110
#define USBCPOWER3_PTN_POWER_CONTROL_FRS_DIS   0x00
 USB-C Power 3 PTN USB PD POWER_CONTROL register setting.
#define USBCPOWER3_PTN_POWER_CONTROL_FRS_EN   0x80
#define USBCPOWER3_PTN_POWER_CONTROL_FRS_MASK   0x80
#define USBCPOWER3_PTN_POWER_CONTROL_VBUS_V_MON_EN   0x00
#define USBCPOWER3_PTN_POWER_CONTROL_VBUS_V_MON_DIS   0x40
#define USBCPOWER3_PTN_POWER_CONTROL_VBUS_V_MON_MASK   0x40
#define USBCPOWER3_PTN_POWER_CONTROL_DIS_V_ALARM_EN   0x00
#define USBCPOWER3_PTN_POWER_CONTROL_DIS_V_ALARM_DIS   0x20
#define USBCPOWER3_PTN_POWER_CONTROL_DIS_V_ALARM_MASK   0x20
#define USBCPOWER3_PTN_POWER_CONTROL_AUTO_DISCH_DIS   0x00
#define USBCPOWER3_PTN_POWER_CONTROL_AUTO_DISCH_EN   0x10
#define USBCPOWER3_PTN_POWER_CONTROL_AUTO_DISCH_MASK   0x10
#define USBCPOWER3_PTN_POWER_CONTROL_BLEED_DISCH_DIS   0x00
#define USBCPOWER3_PTN_POWER_CONTROL_BLEED_DISCH_EN   0x08
#define USBCPOWER3_PTN_POWER_CONTROL_BLEED_DISCH_MASK   0x08
#define USBCPOWER3_PTN_POWER_CONTROL_FORCE_DISCH_DIS   0x00
#define USBCPOWER3_PTN_POWER_CONTROL_FORCE_DISCH_EN   0x04
#define USBCPOWER3_PTN_POWER_CONTROL_FORCE_DISCH_MASK   0x04
#define USBCPOWER3_PTN_POWER_CONTROL_VCONN_1W   0x00
#define USBCPOWER3_PTN_POWER_CONTROL_VCONN_DEV_CAP   0x02
#define USBCPOWER3_PTN_POWER_CONTROL_VCONN_MASK   0x02
#define USBCPOWER3_PTN_POWER_CONTROL_VCONN_SRC_DIS   0x00
#define USBCPOWER3_PTN_POWER_CONTROL_VCONN_SRC_EN   0x01
#define USBCPOWER3_PTN_POWER_CONTROL_VCONN_SRC_MASK   0x01
#define USBCPOWER3_PTN_CC_STATUS_LOOKING_4_CONNECTION   0x20
 USB-C Power 3 PTN USB PD CC_STATUS register setting.
#define USBCPOWER3_PTN_CC_STATUS_CONNECT_RESULT_SRC   0x00
#define USBCPOWER3_PTN_CC_STATUS_CONNECT_RESULT_SINK   0x10
#define USBCPOWER3_PTN_CC_STATUS_CONNECT_RESULT_MASK   0x10
#define USBCPOWER3_PTN_CC_STATUS_CC2_OPEN   0x00
#define USBCPOWER3_PTN_CC_STATUS_CC2_SRC_RA   0x04
#define USBCPOWER3_PTN_CC_STATUS_CC2_SRC_RD   0x08
#define USBCPOWER3_PTN_CC_STATUS_CC2_SINK_DEFAULT   0x04
#define USBCPOWER3_PTN_CC_STATUS_CC2_SINK_POWER_1_5   0x08
#define USBCPOWER3_PTN_CC_STATUS_CC2_SINK_POWER_3_0   0x0C
#define USBCPOWER3_PTN_CC_STATUS_CC2_MASK   0x0C
#define USBCPOWER3_PTN_CC_STATUS_CC1_OPEN   0x00
#define USBCPOWER3_PTN_CC_STATUS_CC1_SRC_RA   0x01
#define USBCPOWER3_PTN_CC_STATUS_CC1_SRC_RD   0x02
#define USBCPOWER3_PTN_CC_STATUS_CC1_SINK_DEFAULT   0x01
#define USBCPOWER3_PTN_CC_STATUS_CC1_SINK_POWER_1_5   0x02
#define USBCPOWER3_PTN_CC_STATUS_CC1_SINK_POWER_3_0   0x03
#define USBCPOWER3_PTN_CC_STATUS_CC1_MASK   0x03
#define USBCPOWER3_PTN_POWER_STATUS_DEBUG_CONNECTED   0x80
 USB-C Power 3 PTN USB PD POWER_STATUS register setting.
#define USBCPOWER3_PTN_POWER_STATUS_TCPC_INIT   0x40
#define USBCPOWER3_PTN_POWER_STATUS_SRC_HIGH_V   0x20
#define USBCPOWER3_PTN_POWER_STATUS_SRC_VBUS_EN   0x10
#define USBCPOWER3_PTN_POWER_STATUS_VBUS_DET_EN   0x08
#define USBCPOWER3_PTN_POWER_STATUS_VBUS_PRESENT   0x04
#define USBCPOWER3_PTN_POWER_STATUS_VCONN_PRESENT   0x02
#define USBCPOWER3_PTN_POWER_STATUS_SINKING_VBUS   0x01
#define USBCPOWER3_PTN_COMMAND_WAKE_I2C   0x11
 USB-C Power 3 PTN USB PD COMMAND register setting.
#define USBCPOWER3_PTN_COMMAND_DIS_VBUS_DETECT   0x22
#define USBCPOWER3_PTN_COMMAND_EN_VBUS_DETECT   0x33
#define USBCPOWER3_PTN_COMMAND_DIS_SINK_VBUS   0x44
#define USBCPOWER3_PTN_COMMAND_EN_SINK_VBUS   0x55
#define USBCPOWER3_PTN_COMMAND_DIS_SRC_VBUS   0x66
#define USBCPOWER3_PTN_COMMAND_SRC_VBUS_DEF_V   0x77
#define USBCPOWER3_PTN_COMMAND_SRC_VBUS_HIGH_V   0x88
#define USBCPOWER3_PTN_COMMAND_LOOK_4_CONNECTION   0x99
#define USBCPOWER3_PTN_COMMAND_RX_ONE_MORE   0xAA
#define USBCPOWER3_PTN_COMMAND_SEND_FRS_SIGNAL   0xCC
#define USBCPOWER3_PTN_COMMAND_RESET_TRANSMIT_BUFFER   0xDD
#define USBCPOWER3_PTN_COMMAND_RESET_RECEIVE_BUFFER   0xEE
#define USBCPOWER3_PTN_COMMAND_I2C_IDLE   0xFF
#define USBCPOWER3_PTN_TIMEOUT_MS   5000
 USB-C Power 3 PTN USB PD timeout setting.
#define USBCPOWER3_DEVICE_ADDRESS_PTN_GND   0x50
 USB-C Power 3 device address setting.
#define USBCPOWER3_DEVICE_ADDRESS_PTN_10K_BYPASS   0x51
#define USBCPOWER3_DEVICE_ADDRESS_PTN_UNCONNECTED   0x52
#define USBCPOWER3_DEVICE_ADDRESS_PTN_100K_BYPASS   0x53
#define USBCPOWER3_DEVICE_ADDRESS_PTN   USBCPOWER3_DEVICE_ADDRESS_PTN_GND
#define USBCPOWER3_DEVICE_ADDRESS_ACT   0x24
#define USBCPOWER3_MAP_MIKROBUS(cfg, mikrobus)
 MikroBUS pin mapping.

Enumerations

enum  usbcpower3_return_value_t { USBCPOWER3_OK = 0 , USBCPOWER3_ERROR = -1 }
 USB-C Power 3 Click return value data. More...

Functions

void usbcpower3_cfg_setup (usbcpower3_cfg_t *cfg)
 USB-C Power 3 configuration object setup function.
err_t usbcpower3_init (usbcpower3_t *ctx, usbcpower3_cfg_t *cfg)
 USB-C Power 3 initialization function.
err_t usbcpower3_ptn_write_reg_byte (usbcpower3_t *ctx, uint8_t reg, uint8_t data_in)
 USB-C Power 3 PTN write register byte function.
err_t usbcpower3_ptn_read_reg_byte (usbcpower3_t *ctx, uint8_t reg, uint8_t *data_out)
 USB-C Power 3 PTN read register byte function.
err_t usbcpower3_ptn_write_reg_word (usbcpower3_t *ctx, uint8_t reg, uint16_t data_in)
 USB-C Power 3 PTN write register word function.
err_t usbcpower3_ptn_read_reg_word (usbcpower3_t *ctx, uint8_t reg, uint16_t *data_out)
 USB-C Power 3 PTN read register word function.
err_t usbcpower3_ptn_write_reg_block (usbcpower3_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
 USB-C Power 3 PTN write register block function.
err_t usbcpower3_ptn_read_reg_block (usbcpower3_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
 USB-C Power 3 PTN read register block function.
err_t usbcpower3_act_write_reg (usbcpower3_t *ctx, uint8_t reg, uint8_t data_in)
 USB-C Power 3 ACT write register function.
err_t usbcpower3_act_read_reg (usbcpower3_t *ctx, uint8_t reg, uint8_t *data_out)
 USB-C Power 3 ACT read register function.
err_t usbcpower3_ptn_read_info (usbcpower3_t *ctx)
 USB-C Power 3 PTN read device information function.
void usbcpower3_enable_device (usbcpower3_t *ctx)
 USB-C Power 3 device enable function.
void usbcpower3_disable_device (usbcpower3_t *ctx)
 USB-C Power 3 device disable function.
void usbcpower3_restart_device (usbcpower3_t *ctx)
 USB-C Power 3 device restart function.
err_t usbcpower3_wait_tcpc_init (usbcpower3_t *ctx)
 USB-C Power 3 wait TCPC init function.
void usbcpower3_set_high_current (usbcpower3_t *ctx)
 USB-C Power 3 set high current function.
void usbcpower3_set_low_current (usbcpower3_t *ctx)
 USB-C Power 3 set low current function.
uint8_t usbcpower3_get_int_pin (usbcpower3_t *ctx)
 USB-C Power 3 get interrupt pin function.
uint8_t usbcpower3_get_fen_pin (usbcpower3_t *ctx)
 USB-C Power 3 get FEN pin function.

Detailed Description

This file contains API for USB-C Power 3 Click Driver.

Enumeration Type Documentation

◆ usbcpower3_return_value_t

USB-C Power 3 Click return value data.

Predefined enum values for driver return values.

Enumerator
USBCPOWER3_OK 
USBCPOWER3_ERROR